﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

///<summary>
///
///</summary>
public class SplitEnemyComponent : MonoBehaviour
{
    Vector3 Gravity;
    Vector3 angles;
    public Vector3 pos;
    public int direction;
    Vector2 initPos;
    Vector3 initAngles;
    // Start is called before the first frame update
    private void OnEnable()
    {
        initPos = transform.parent.position;
        transform.position = initPos;
        initAngles = transform.eulerAngles;
    }
    private void FixedUpdate()
    {
       transform.Translate(pos*3.5f);
       angles.z = direction * Mathf.Atan((5 + Gravity.y) / 2) * Mathf.Rad2Deg; 
        transform.eulerAngles += angles * Time.deltaTime;
    }
    private void OnDisable()
    {
        transform.position = initPos;
        transform.eulerAngles = initAngles;
    }
}
